Carbon


TruncString

Header: TextUtils.h Carbon status: Supported

Ensures that a Pascal string fits into the specified pixel width, by truncating the string as necessary. This function makes use of the current script and font.

SInt16 TruncString (
    SInt16 width, 
    Str255 theString, 
    TruncCode truncWhere
);
Parameter descriptions
width

The number of pixels in which the string must be displayed in the current script and font.

theString

The Pascal string to be displayed. On output, contains a version of the string that has been truncated (if necessary) to fit in the number of pixels specified by width.

truncWhere

A constant that indicates where the string should be truncated. If you supply the truncEnd value, characters are truncated off the end of the string. If you supply the truncMiddle value, characters are truncated from the middle of the string; this is useful when displaying pathnames.

DISCUSSION

The TruncString function ensures that a Pascal string fits into the pixel width specified by the width parameter by modifying the string, if necessary, through truncation. TruncString uses the font script to determine how to perform truncation. If truncation occurs, TruncString inserts a truncation indicator, which is the ellipsis (…) in the Roman script system. You can specify which token to use for indicating truncation as the tokenEllipsis token type in the untoken table of a tokens ('itl4') resource.

To determine the width of a string in the current font and script, use the QuickDraw StringWidth function.

SPECIAL CONSIDERATIONS

TruncString may move memory; your application should not call this function at interrupt time.

AVAILABILITY

Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)